<?php
namespace Controller;

class CsvRowdataBuilder
{
    static $_instance = null;
    private $list = null;

    private function __construct()
    {

    }

    private function __clone()
    {

    }

    static function getInstance()
    {
        if (!isset(self::$_instance) || is_null(self::$_instance)) {
            self::$_instance = new self();
        }

        return self::$_instance; 
    }

    public function buildData($list, $method)
    {
        if (empty($list)) {
            return false;
        }

        $this->list = $list;

        return $this->$method();
    }

    public function pay_account_cash_out()
    {
        $status = [
            -2 => '退款',
            -1 => '撤销',
            '未结算',
            '结算',
            '在途资金'
            ];

        $rowData = array(
            ' '.$this->list['co_caid'],
            ' '.$this->list['co_userNick'],
            ' '.$this->list['co_uid'],
            ' '.$this->list['co_cardaddr'],
            ' '.$this->list['co_account'],
            ' '.$this->list['co_money'],
            ' '.$this->list['co_tax'],
            ' '.number_format(($this->list['co_money'] - $this->list['co_tax']),2),
            ' T+'.$this->list['co_day'],
            ' '.$this->list['co_toCardType'],
            ' '.$this->list['co_arriveDateTime'],
            ' '.$this->list['co_day_time'],
            ' '.$status[$this->list['co_state']],
            ' '.$this->list['co_operId'],
            ' '.$this->list['co_operTime'],
            ' '.$this->list['co_memo'],
            ' '.$this->list['co_reason'],
        );

        unset($this->list);
        return $rowData;
    }

    public function cate_score_tran()
    {
        $rowData = array(
            ' '.$this->list['sc_id'],
            $this->list['sc_createTime'],
            ' '.$this->list['sc_orderId'],
            $this->list['sc_businessId'],
            $this->list['sc_unick'],
            '积分账户',
            $this->list['sc_createTime'],
            $this->list['sc_score'],
            $this->list['sc_type'],
            $this->list['sc_balance'],
            $this->list['sc_operId'],
            $this->list['sc_operId'],
            $this->list['sc_sourceUser'],
            $this->list['sc_memo'],
        );

        unset($list);
        return $rowData;
    }
}
